﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Mindfor.Web
{
	/// <summary>
	/// Attribute causes automatic loads from TempData form data to ViewData and/or model state.
	/// </summary>
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited=true, AllowMultiple=false)]
	public class LoadModelStateAttribute : FilterAttribute, IActionFilter
	{
		/// <summary>
		/// Called before action method executes.
		/// </summary>
		/// <param name="filterContext">The filter context.</param>
		public void OnActionExecuting(ActionExecutingContext filterContext)
		{
			filterContext.Controller.LoadModelState();
		}

		public void OnActionExecuted(ActionExecutedContext filterContext)
		{
		}
	}
}
